package com.liutaw.nanjingair.views.activities.products;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.ListView;

import com.liutaw.nanjingair.R;
import com.liutaw.nanjingair.views.activities.base.BaseActivity;
import com.liutaw.nanjingair.views.adapter.WarningAdapter;
import com.liutaw.navigationbarlib.NaviBarBuilder;
import com.szjlxh.data.repository.ProductWeatherRepository;
import com.szjlxh.domain.model.product.WarningInfo;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import rx.Scheduler;
import rx.Subscriber;

public class WeatherWaringActivity extends BaseActivity {
    public static Intent getCallingIntent(Context context) {
        return new Intent(context, WeatherWaringActivity.class);
    }

    @Bind(R.id.listview)
    ListView listview;

    ProductWeatherRepository repository;

    @Override
    protected int getLayoutResId() {
        return R.layout.layout_weather_waring;
    }

    @Override
    protected void initNaviBar(NaviBarBuilder naviBarBuilder) {
    }

    @Override
    protected String getCusTitle() {
        return "气象预警";
    }

    @Override
    protected void initOnCreate() {
        repository = new ProductWeatherRepository();
        repository.weatherWarningWeather().subscribe(new Subscriber<List<WarningInfo>>() {
            @Override
            public void onCompleted() {

            }

            @Override
            public void onError(Throwable e) {

            }

            @Override
            public void onNext(List<WarningInfo> warningInfos) {
                listview.setAdapter(new WarningAdapter(WeatherWaringActivity.this,warningInfos));
            }
        });
    }

    @Override
    protected void initCusView(View view) {
        ButterKnife.bind(this, view);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        ButterKnife.unbind(this);
    }
}
